package com.atguigu.doubles.linklist;

import com.atguigu.doubles.DoubleNode;

/**
 * @ClassName Test
 * @DeScription 双向链表测试类
 * @Author 剧情再美终是戏
 * @Date 2019/11/20 20:27
 * @Version 1.0
 **/
public class Test {

    public static void main(String[] args) {

        // 初始化节点
        DoubleNode doubleNode1 = new DoubleNode(1, "1", "1");
        DoubleNode doubleNode2 = new DoubleNode(2, "2", "2");
        DoubleNode doubleNode3 = new DoubleNode(3, "3", "3");
        DoubleNode doubleNode4 = new DoubleNode(4, "4", "4");
        DoubleLinkList doubleLinkList = new DoubleLinkList();


        // 向尾部添加元素
//        doubleLinkList.add(doubleNode1);
//        doubleLinkList.add(doubleNode4);
//        doubleLinkList.add(doubleNode3);
//        doubleLinkList.add(doubleNode2);
//        System.out.println("向尾部添加元素,输出：");
//        doubleLinkList.list();

        // 有序添加
        doubleLinkList.addByOrder(doubleNode1);
        doubleLinkList.addByOrder(doubleNode4);
        doubleLinkList.addByOrder(doubleNode3);
        doubleLinkList.addByOrder(doubleNode2);
        System.out.println("有序添加,输出：");
        doubleLinkList.list();

        // 修改
        doubleNode3.setName("33");
        doubleNode3.setDes("33");
        doubleLinkList.update(doubleNode3);
        System.out.println("修改后,输出：");
        doubleLinkList.list();

        // 删除
        doubleLinkList.del(3);
        System.out.println("删除,输出：");
        doubleLinkList.list();
    }


}
